from faker import Faker
import pandas as pd  # 别名 pd

fake = Faker(locale="zh_CN")


def init_emp_data(n=1, filepath=""):
    data_list = []
    for i in range(n):
        employee = {
            "员工编号": fake.uuid4(),
            "姓名": fake.name(),
            "年龄": fake.random_int(min=18, max=65),
            "城市": fake.city(),
            "职位": fake.job(),
            "邮箱": fake.email(),
            "电话号码": fake.phone_number(),
            "入职日期": fake.date_this_decade(),
            "工资": fake.random_int(min=3000, max=20000),
            "身份证号": fake.ssn(),
            "家庭地址": fake.address(),
        }
        data_list.append(employee)

    df = pd.DataFrame(data_list)  # 格式化数据，得到新的对象 csv
    with pd.ExcelWriter(filepath) as writer:
        df.to_excel(writer)


if __name__ == "__main__":
    init_emp_data(50, "emp.xlsx")
